package com.xkdx.guangguang.util;

import android.app.Dialog;
import android.content.Context;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.xkdx.caipiao.R;
import com.xkdx.guangguang.module.statics.IConstants;

public class DialogFactory {

	private  static TextView titleTxtv;
	private  static ProgressBar pb;
	private  static Button btn_dialog;
	

	public static Dialog creatRequestDialog(final Context context, String tip) {

		final Dialog dialog = new Dialog(context, R.style.dialog);
		dialog.setContentView(R.layout.dialog_layout);
		Window window = dialog.getWindow();
		WindowManager.LayoutParams lp = window.getAttributes();
		int width = IConstants.getScreenWidth(context);
		lp.width = (int) (0.8 * width);

		titleTxtv = (TextView) dialog.findViewById(R.id.tvLoad);
		pb = (ProgressBar) dialog.findViewById(R.id.pb);
		btn_dialog = (Button) dialog.findViewById(R.id.btn_dialog);

		if (tip == null || tip.length() == 0) {
			titleTxtv.setText("数据请求中，请耐心等待...");
		} else {

			setMessage(tip);
		}

		return dialog;
	}

	public static  void setPbVisable(int view) {
		pb.setVisibility(view);
	}

	public static  void setMessage(String message) {
		titleTxtv.setText(message);
	}

	public  static void setClick(OnClickListener l) {
		btn_dialog.setOnClickListener(l);
	}
	
	public static  void setBtnVisable(int view) {
		btn_dialog.setVisibility(view);
	}
	
	public static  void setBtnMessage(String message) {
		btn_dialog.setText(message);
	}


}
